<!DOCTYPE html>
<html>
<head>
    <title>攻略系列</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css"/>
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/strategyCatalogs.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css"/>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <script src="/js/common.js"></script>

</head>
<script>
    $(function () {
        //拿到大攻略的id
        var strategyId = getParams().strategyId;
        //页面加载完成后从地址栏上获取到指定的大攻略的id,发送get请求获取攻略分类和攻略分类下的文章
        $.get("/strategys/"+strategyId+"/catalogs",function (data) {

            var num = 1 ;//记录攻略分类的前缀

            $("#title").html(data[0].strategyTitle);
            // //渲染数据
            $(".catalogs").renderValues({list:data},{
                handle:function (ele, value) {
                    ele.href = "/strategyDetails.html?id="+value;
                },
                showTitle:function (ele, value) {
                    var content = num+++"/"+value ;//每次循环调用的这个参数都会将当前的这个函数，所以这个内容每次都是新的

                    if(num<10){
                        //分类循环次数少于10的话就在前面加个0
                        content = 0 + content;
                    }
                    ele.innerHTML = content ;
                }
            });
        })

        //获取大攻略相关标签
        $.get("/strategys/"+strategyId+"/comment/labels",function (data) {
            //回显标签
            $(".tag").renderValues(data);
        })

        //获取大攻略的点评
        $.get("/strategys/"+strategyId+"/comments",function (data) {
            console.log(data);
            //回显点评
            $("#comment").renderValues(data,{
                starHandler:function (ele,value) {
                    var num = 0;
                    while (num<value){
                        $(ele).append('<i class="fa fa-star"></i>');
                        num++;
                    }
                    while(num<5){
                        $(ele).append('<i class="fa fa-star-o"></i>');
                        num++;
                    }
                },
                userHandler:function (ele,value) {
                    ele.href="/userProfiles.html?id="+value;
                },
                commentHandler:function (ele,value) {
                    ele.href="strategyComment.html?id="+value;
                }
            });
        })

        //跳转到点评页面
        $("#commentBtn").click(function () {
            location.href="/addComment.html?strategyId="+strategyId;
        })

        //获取浏览量为前三的游记
        $.get("/travelsForBrowse",{id:strategyId},function (data) {
            //渲染数据
            $(".hot").renderValues({list:data}, {
                showBrowse: function (ele, value) {
                    ele.href = "/travelContent.html?id="+value;
                }
            });
        })

    })
</script>
<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col-2">
            <a href="javascript:history.go(-1);">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">
            <div class="input-group-sm search">
                <input class="form-control searchBtn" placeholder="搜索旅行攻略">
            </div>
        </div>
    </div>
</div>

<div class="container strategies">
    <h5 class="title" id="title"></h5>
    <small><span>0</span>人阅读过此攻略</small>
    <div class="focus">
        <i class="fa fa-heart"><span> 0</span> 收藏</i>
        <i class="fa fa-thumbs-up"><span> 0</span> 点赞</i>
        <button class="btn">想去</button>
        <button class="btn">去过</button>
    </div>
</div>
<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab">
    <li class="nav-item ">
        <a class="nav-link active" id="pills-catalog-tab" data-toggle="pill" href="#pills-catalog">
            <span>攻略目录</span>
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link " id="pills-comment-tab" data-toggle="pill" href="#pills-comment">
            <span>骡友点评</span>
        </a>
    </li>
</ul>
<div class="tab-content " id="pills-tabContent">
    <div class="tab-pane fade show active" id="pills-catalog">
        <div class="container hot">
            <h6>大家都在看</h6>
            <div render-loop="list">
                <a href="travelContent.html" render-key="list.id" render-fun="showBrowse">
                    <button class="btn" render-html="list.title"></button>
                </a>
            </div>
        </div>
        <div class="catalogs">
            <div render-loop="list">
                <div class="container detail">
                    <!--01/概况-->
                    <h6 render-key="list.name" render-fun="showTitle"></h6>
                    <div render-loop="list.strategyDetail">
                        <a render-key="list.strategyDetail.id" render-fun="handle">
                            <button class="btn" render-html="list.strategyDetail.title"></button>
                        </a>

                    </div>
                </div>

            </div>
        </div>

    </div>
    <div class="tab-pane fade " id="pills-comment">

        <div class="container tag">
            <h6>骡友标签</h6>
            <div render-loop="list">
                <span render-html="list.content"></span>
            </div>
        </div>
        <hr>

        <div id="comment">
            <div render-loop="list">
                <div class="container row comment">
                    <div class="col-2 comment-head">
                        <a href="userProfiles.html" render-key="list.author.id" render-fun="userHandler">
                            <img class="rounded-circle"
                                 render-src="list.author.headImgUrl">
                        </a>
                    </div>
                    <div class="col comment-right">
                        <p class="authorName"><span render-html="list.author.nickName"></span></p>
                        <span class="comment-star" render-key="list.grade" render-fun="starHandler"></span>
                        <span class="comment-date" render-html="list.createDate"></span>
                        <div class="comment-content">
                            <a  render-key="list.id" render-fun="commentHandler">
                                <p render-html="list.content"></p>
                            </a>
                        </div>

                        <ul class="comment-img" render-loop="list.images">
                            <li>
                                <img render-src="list.images.imageUrl">
                            </li>
                        </ul>

                        <div class="d-flex icon">
                            <a render-key="list.id" render-fun="commentHandler">
                                <i class="fa  fa-commenting-o " style="margin-right: 10px"> 评论 </i>
                            </a>
                            <i class="fa fa-thumbs-o-up"> <span>0</span> </i>
                        </div>

                    </div>
                </div>

            </div>
        </div>
    </div>

</div>
</div>

<div class="operation">
    <button class="btn">加入旅行单</button>
    <button class="btn" id="commentBtn" >点评</button>
</div>


</body>
</html>